//
//  MBLocationManager.h
//  iNaviCore
//
//  Created by fanyunlong on 2016/11/15.
//  Copyright © 2016年 Mapbar. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "MBNaviCoreBase.h"

typedef enum
{
    MBGpsDeviceState_off = 0,
    MBGpsDeviceState_connecting = 1,
    MBGpsDeviceState_ok = 2
} MBGpsDeviceState;

/*
 *  主辅路或高架桥的选项。当同时存在主辅路和高架桥时，会使用高架桥选项。
 */
typedef enum {
    MBSwitchChoice_none = 0,
    MBSwitchChoice_inMainRoad,  // 表示当前为主辅路选项，此时在主路上或设置到主路上
    MBSwitchChoice_inSideRoad,  // 表示当前为主辅路选项，此时在辅路上或设置到辅路上
    MBSwitchChoice_upBridge,    // 表示当前为高架路选项，此时在高架路上或设置到高架路上
    MBSwitchChoice_downBridge   // 表示当前为高架路选项，此时为非高架路上或设置到非高架路上
}MBSwitchChoice;

@class MBLocationManager;
@class MBGpsInfo;

@protocol MBLocationManagerDelegate <NSObject>

@optional
-(void)mbLocationManagerGpsConnected:(MBLocationManager*)mgr;
-(void)mbLocationManagerGpsDisconnected:(MBLocationManager*)mgr;
-(void)mbLocationManagerGpsConnectedForDisplay:(MBLocationManager*)mgr;
-(void)mbLocationManagerGpsDisconnectedForDisplay:(MBLocationManager*)mgr;
/**
 * 正常定位下在有位置发生改变会有回调产生，如果客户端打开了 GPS 推演模式 (MBNaviSessionParams allowTunnelGpsPredicting = YES)，则在隧道中每秒会有一次。
 */
-(void)mbLocationManager:(MBLocationManager*)mgr gpsUpdate:(MBGpsInfo*)gpsInfo;
-(void)mbLocationManagerEnterFreeMode:(MBLocationManager*)mgr;
-(void)mbLocationManagerExitFreeMode:(MBLocationManager*)mgr;

/**
 * 主辅路或高架桥的选项开始和结束事件，仅支持离线数据；可用MBLocatioinSimulator测试
 */
-(void)mbLocationManager:(MBLocationManager *)mgr beginSwitchChoice:(MBSwitchChoice)choice;
-(void)mbLocationManager:(MBLocationManager *)mgr endSwitchChoice:(MBSwitchChoice)choice;

@end

@interface MBLocationManager : NSObject

+(instancetype)sharedInstance;

+(void)cleanup;
/**
 *  从实际设备获取GPS数据，若使用MBLocationSimulator模拟日志后，需调用此方法获取真实GPS数据。
 */
+(void)openDevice;

@property (nonatomic, assign) id<MBLocationManagerDelegate> delegate;
@property (nonatomic, readonly) BOOL supportGyroscope;
@property (nonatomic, readonly) BOOL isPredicting;

/**
 *  手动切换主辅路／上下高架桥
 */
- (BOOL)setSwitchChoice:(MBSwitchChoice)switchChoice;
- (MBSwitchChoice)getSwitchChoice;

/**
 *  手动切换路径
 */
-(void)switchPathByPosition:(MBPoint)point;

/**
 *  WeLink 客户端使用
 */
@property (nonatomic, strong) MBGpsInfo* currentGPSInfo;
@property (nonatomic, readonly) MBGpsDeviceState gpsState;
@property(nonatomic) BOOL allowsBackgroundLocationUpdates;

-(void)enableUpdateGps:(BOOL)enable;
-(BOOL)startLogging:(NSString*)filename;
-(void)stopLogging;

@end
